package game.uno.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;

public class Network 
{
	Socket clientSocket;
	
	PrintWriter clientOutput;
	BufferedReader clientInput;
	
	String fromServer;

	public Network()
	{
		try
		{
			clientSocket = new Socket("localhost", 779);
			clientOutput = new PrintWriter(clientSocket.getOutputStream(), true);
			clientInput = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
			
			while((fromServer = clientInput.readLine()) != null)
			{
				System.out.println("Server: " + fromServer);
			}
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
		
		try 
		{
			clientSocket.close();
			clientOutput.close();
			clientInput.close();
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
	}
}
